<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('商编查询')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="downloadTransactionDetailForm">
                    <div class="select-list">
                        <ul>
                            <input type="hidden" name="bno" th:value="${bno}">
                            <li>
                                <label style="width: 80px">系统商户号：</label>
                                <input type="text" name="merchantNo"/>
                            </li>
                            <li>
                                <label>流水号：</label>
                                <input type="text" name="serial"/>
                            </li>
                            <li>
                                <label>交易状态：</label>
                                <select name="status">
                                    <option value="">所有</option>
                                    <option value="0">成功</option>
                                    <option value="1">补录</option>
                                    <option value="-1">撤销</option>
                                    <option value="-2">冲正</option>
                                    <option value="2">失败</option>
                                </select>
                            </li>
                            <li>
                                <label >交易类型：</label>
                                <select name="msgType">
                                    <option value="">所有</option>
                                    <option value="H007">消费</option>
                                    <option value="Y007">押金消费</option>
                                    <option value="S007">流量卡费</option>
                                    <option value="H014">退货</option>
                                </select>
                            </li>
                            <li>
                                <label>清算状态：</label>
                                <select name="settStatus">
                                    <option value="">所有</option>
                                    <option value="0">未清算</option>
                                    <option value="1">已清算</option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 80px">清算类型：</label>
                                <select name="settType">
                                    <option value="">所有</option>
                                    <option value="0">D0</option>
                                    <option value="1">T1</option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label>交易日期：</label>
                                <input type="text" class="time-input" id="startDate" placeholder="开始时间" name="startDate"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endDate" placeholder="结束时间" name="endDate"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">

                <a class="btn btn-success" onclick="downloadTransactionDetail()">
                    <i class="fa fa-download"></i> 交易导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" class="table text-nowrap"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "ReportMerchant";

        $(function() {
          var options = {
            url: prefix + "/getTransactionDetailList",
            clickToSelect: true,
            modalName: "商编查询",
            columns: [{
                radio: true
              },
              {
                field: 'SERIAL',
                title: '流水号'
              },
              {
                field: 'MER_NO',
                title: '系统商户编号'
              },
              {
                field: 'MER_NAME',
                title: '商户名称'
              },
              {
                field: 'AGENT_NO',
                title: '服务商编号'
              },
              {
                field: 'SCREEN_NAME',
                title: '结算人'
              },
              {
                field: 'MSGTYPE',
                title: '交易类型',
                formatter: function (value, row, index) {
                    return typeTools(value);
                }
              },
              {
                field: 'TERNO',
                title: '终端号'
              },
              {
                field: 'LOCALDATE',
                title: '交易时间',
                  formatter:function (value, row, index) {
                      return $.table.tooltip(value,5);
                  }
              },
              {
                field: 'PAN',
                title: '交易卡号'
              },
              {
                field: 'AMOUNT',
                title: '交易金额'
              },
              {
                field: 'STATUS',
                title: '交易状态',
                  formatter: function (value, row, index) {
                      return statusTools(value);
                  }
              },
              {
                field: 'CARDTYPE',
                title: '卡类型',
                  formatter: function (value, row, index) {
                      return cardTypeTools(value);
                  }
              },
              {
                field: 'SETT_TYPE',
                title: '清算类型',
                  formatter: function (value, row, index) {
                      return settTypeTools(value);
                  }
              },
              {
                field: 'AU_STATE',
                title: '清算状态',
                  formatter: function (value, row, index) {
                      return auStateTools(value);
                  }
              },
              {
                field: 'BNO',
                title: '渠道商户编号'
              }]
          };
            $.table.init(options);
        });


        function downloadTransactionDetail() {
            $.modal.confirm("请检查好导出条件,确认是否导出？", function() {
                $.operate.submit(prefix + "/downloadTransactionDetail", "post", "json", $('#downloadTransactionDetailForm').serialize());
            });
        }

        /* 交易类型显示 */
        function typeTools(value) {
            if (value == 'H007') {
                return '消费';
            } else if(value == 'V007'){
                return '会员交易';
            } else if(value == 'H900'){
                return '参数下载';
            } else if(value == 'H000'){
                return '签到';
            } else if(value == 'H901'){
                return '公钥下载';
            } else if(value == 'H902'){
                return '主密钥交换、下载';
            } else if(value == 'H903'){
                return 'IC公钥、参数查询';
            } else if(value == 'H904'){
                return 'IC公钥、参数下载';
            } else if(value == 'H002'){
                return '余额查询';
            } else if(value == 'H014'){
                return '退货';
            } else if(value == 'H013'){
                return '冲正';
            } else if(value == 'H905'){
                return '应用版本更新查询';
            } else if(value == 'H906'){
                return '电子签名数据上送';
            }
        }
        /* 交易状态显示 */
        function statusTools(value) {
            if (value == '0') {
                return '成功';
            } else if(value == '1'){
                return '补录';
            } else if(value == '2'){
                return '失败';
            } else if(value == '-1'){
                return '撤销';
            } else if(value == '-2'){
                return '冲正';
            } else if(value == '20'){
                return '待撤销';
            } else if(value == '50'){
                return '待冲正';
            }
        }
        /* 卡类型显示 */
        function cardTypeTools(value) {
            if (value == '0') {
                return '未知';
            } else if(value == '1'){
                return '借记卡';
            } else if(value == '2'){
                return '贷记卡';
            } else if(value == '3'){
                return '预付费卡';
            }
        }
        /* 清算类型显示 */
        function settTypeTools(value) {
            if (value == '0') {
                return 'D0';
            } else if(value == '1'){
                return 'T1';
            }
        }
        /* 清算状态显示 */
        function auStateTools(value) {
            if (value == '0') {
                return '未清算';
            } else if(value == '1'){
                return '已清算';
            }
        }
    </script>
</body>
</html>